<template>
  <el-card>
    <div slot="header" class="hearder">
      <div class="search-header">
        <span>线上热门搜索</span>
        <el-dropdown>
          <span>
            <i class="el-icon-more"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>黄金糕</el-dropdown-item>
            <el-dropdown-item>狮子头</el-dropdown-item>
            <el-dropdown-item>螺蛳粉</el-dropdown-item>
            <el-dropdown-item>双皮奶</el-dropdown-item>
            <el-dropdown-item>蚵仔煎</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>

    <div>
      <el-row :gutter="10">
        <el-col :span="12">
          <lineCharts />
        </el-col>

        <el-col :span="12">
          <lineChartsRight />
        </el-col>
      </el-row>

      <el-table
        :data="[tableData[page - 1]]"
        style="width: 100%; margin-top: 10px"
        border
      >
        <el-table-column prop="id" label="排名" width="80"> </el-table-column>
        <el-table-column prop="word" label="搜索关键字" width="180">
        </el-table-column>
        <el-table-column prop="user" label="用户数" sortable> </el-table-column>
        <el-table-column prop="count" label="周涨幅" sortable>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page.sync="page"
        :page-size="1"
        class="pagenation"
        layout="prev, pager, next"
        :total="tableData.length"
      >
      </el-pagination>
    </div>
  </el-card>
</template>

<script>
import lineCharts from "./lineCharts";
import lineChartsRight from "./lineChartsRight";
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState({
      listState: (state) => state.home.list,
    }),
  },
  components: {
    lineCharts,
    lineChartsRight,
  },
  data() {
    return {
      page: 1,
      tableData: [],
    };
  },
  watch: {
    listState() {
      this.listState.searchWord.map((item, index) => {
        return (item.id = index + 1);
      });
      this.tableData = this.listState.searchWord;
    },
  },
};
</script>

<style scoped>
.search-header {
  display: flex;
  justify-content: space-between;
  /* padding-bottom: 10px; */
  height: 28px;
  align-items: center;
}
.hearder {
  border-bottom: 1px solid #eee;
}
.pagenation {
  float: right;
}
</style>
